package Exer_HiHaiHi;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/3/23 19:44
 * 说明：模拟洗牌和发牌，牌没有顺序(包括大王和小王)
 */

public class CardTest {
    public static void main(String[] args) {
        // 组成一幅扑克牌
        String[] num = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        String[] color = {"黑桃", "红心", "方片", "梅花"};
        ArrayList poker = new ArrayList();
        poker.add("JOKER");
        poker.add("joker");
        for (int i = 0; i < color.length; i++) {
            for (int j = 0; j < num.length; j++) {
                poker.add(color[i] + "-" + num[j]);
            }
        }
        // 洗牌
        Collections.shuffle(poker);
        ArrayList underCard = new ArrayList();
        ArrayList Jimmy = new ArrayList();
        ArrayList Jerry = new ArrayList();
        ArrayList Tom = new ArrayList();

        // 添加底牌
        for (int i = 0; i < 3; i++) {
            underCard.add(poker.get(i));
        }
        for (int i = 3; i < poker.size(); i++) {
            int flag = i % 3;
            switch (flag){
                case 0:
                    Jimmy.add(poker.get(i));
                    break;
                case 1:
                    Jerry.add(poker.get(i));
                    break;
                case 2:
                    Tom.add(poker.get(i));
                    break;
            }
        }
        System.out.println("Jimmy:\n" + Jimmy);
        System.out.println("Jerry:\n" + Jerry);
        System.out.println("Tom:\n" + Tom);
        System.out.println("underCard:\n" + underCard);
    }
}


